// nodeTemplates.js - 导弹电气系统设备节点模板
import { 
  HardwareChipOutline,    // 飞行控制计算机
  AnalyticsOutline,       // 惯性测量单元
  NavigateOutline,        // GPS/INS接收机
  GitMergeOutline,        // 舵机控制器
  RadioOutline,          // 雷达导引头
  ShieldCheckmarkOutline, // 战斗部安全装置
  WifiOutline,           // 数据链终端
  ServerOutline,         // 主电源分配单元
  FlashOutline,          // 热电池
  GitBranchOutline       // 网络交换机
} from '@vicons/ionicons5'

export const nodeTemplates = {
  // SYS-001 飞行控制计算机
  'SYS-001': {
    type: 'SYS-001',
    name: '飞行控制计算机',
    description: '主飞行控制单元，双冗余设计',
    icon: HardwareChipOutline,
    color: '#2080f0',
    subsystem: '制导与控制',
    defaultData: {
      label: '飞行控制计算机',
      type: 'SYS-001',
      specifications: {
        function: '解算飞行轨迹，发出控制指令',
        interfaceCount: 2,
        design: '双冗余设计'
      }
    },
    // 连接器针脚定义 - 基于文档中的J1连接器
    connectors: [
      {
        id: 'J1',
        type: 'J599/23-26-55',
        pinCount: 55,
        pins: [
          { id: 'A1', name: 'PWR_28V_MAIN', type: 'power', direction: 'input', signal: '28V DC, 5A' },
          { id: 'A2', name: 'PWR_RTN', type: 'ground', direction: 'return' },
          { id: 'A5', name: 'RS-422_POS_P', type: 'data', direction: 'input', signal: 'RS-422' },
          { id: 'A6', name: 'RS-422_POS_N', type: 'data', direction: 'input', signal: 'RS-422' },
          { id: 'A7', name: 'ANA_CMD_POS', type: 'analog', direction: 'output', signal: '±10V' },
          { id: 'A8', name: 'ANA_FB_POS', type: 'analog', direction: 'input', signal: '0-5V' },
          { id: 'B1', name: '1553B_BUS_A_P', type: 'bus', direction: 'bidirectional', signal: 'MIL-STD-1553B' },
          { id: 'B2', name: '1553B_BUS_A_N', type: 'bus', direction: 'bidirectional', signal: 'MIL-STD-1553B' },
          { id: 'C1', name: 'DIS_ENG_IGNITE', type: 'discrete', direction: 'output', signal: '28V Open Collector, 2A' },
          { id: 'C2', name: 'ANA_AIRSPEED', type: 'analog', direction: 'input', signal: '0-5V' },
          { id: 'C3', name: 'DIS_TGT_LOCK', type: 'discrete', direction: 'input', signal: '0-5V' },
          { id: 'C4', name: 'ANA_AGC_VOLT', type: 'analog', direction: 'input', signal: '5V TTL' },
          { id: 'C5', name: 'PPS_IN', type: 'discrete', direction: 'input', signal: '5V TTL' },
          { id: 'D1', name: 'ETH_TX_P', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'D2', name: 'ETH_TX_N', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'D3', name: 'ETH_RX_P', type: 'ethernet', direction: 'input', signal: '1000BASE-T' },
          { id: 'D4', name: 'ETH_RX_N', type: 'ethernet', direction: 'input', signal: '1000BASE-T' },
          { id: 'E1', name: 'DIS_SAFE_ARM', type: 'discrete', direction: 'output', signal: '5V TTL' }
        ]
      }
    ]
  },

  // SYS-002 惯性测量单元
  'SYS-002': {
    type: 'SYS-002',
    name: '惯性测量单元',
    description: '测量角速度和加速度，光纤陀螺',
    icon: AnalyticsOutline,
    color: '#18a058',
    subsystem: '制导与控制',
    defaultData: {
      label: '惯性测量单元',
      type: 'SYS-002',
      specifications: {
        function: '提供载体姿态和航向信息',
        technology: '光纤陀螺'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/20-26-35',
        pinCount: 35,
        pins: [
          { id: '1', name: 'PWR_28V', type: 'power', direction: 'input', signal: '28V DC, 1A' },
          { id: '2', name: 'GND', type: 'ground', direction: 'return' },
          { id: '3', name: 'RS-422_TX_P', type: 'data', direction: 'output', signal: 'RS-422' },
          { id: '4', name: 'RS-422_TX_N', type: 'data', direction: 'output', signal: 'RS-422' },
          { id: '5', name: 'RS-422_RX_P', type: 'data', direction: 'input', signal: 'RS-422' },
          { id: '6', name: 'RS-422_RX_N', type: 'data', direction: 'input', signal: 'RS-422' }
        ]
      }
    ]
  },

  // SYS-003 GPS/INS接收机
  'SYS-003': {
    type: 'SYS-003',
    name: 'GPS/INS接收机',
    description: '组合导航系统',
    icon: NavigateOutline,
    color: '#f0a020',
    subsystem: '制导与控制',
    defaultData: {
      label: 'GPS/INS接收机',
      type: 'SYS-003',
      specifications: {
        function: '提供精确位置、速度、时间'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/20-26-30',
        pinCount: 30,
        pins: [
          { id: '1', name: 'PWR_28V', type: 'power', direction: 'input', signal: '28V DC, 1.5A' },
          { id: '2', name: 'GND', type: 'ground', direction: 'return' },
          { id: '3', name: 'RS-422_POS_P', type: 'data', direction: 'output', signal: 'RS-422' },
          { id: '4', name: 'RS-422_POS_N', type: 'data', direction: 'output', signal: 'RS-422' },
          { id: '5', name: 'PPS_OUT', type: 'discrete', direction: 'output', signal: '5V TTL' },
          { id: '6', name: '1553B_BUS_A_P', type: 'bus', direction: 'bidirectional', signal: 'MIL-STD-1553B' },
          { id: '7', name: '1553B_BUS_A_N', type: 'bus', direction: 'bidirectional', signal: 'MIL-STD-1553B' }
        ]
      }
    ]
  },

  // SYS-004 舵机控制器
  'SYS-004': {
    type: 'SYS-004',
    name: '舵机控制器',
    description: '控制舵面偏转，共4个分别控制4个舵面',
    icon: GitMergeOutline,
    color: '#d03050',
    subsystem: '制导与控制',
    defaultData: {
      label: '舵机控制器',
      type: 'SYS-004',
      specifications: {
        function: '接收指令，驱动舵机',
        count: 4
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/18-26-25',
        pinCount: 25,
        pins: [
          { id: '1', name: 'PWR_28V_MOTOR', type: 'power', direction: 'input', signal: '28V DC, 15A' },
          { id: '2', name: 'PWR_RTN_MOTOR', type: 'ground', direction: 'return' },
          { id: '3', name: 'PWR_28V_LOGIC', type: 'power', direction: 'input', signal: '28V DC, 0.5A' },
          { id: '4', name: 'PWR_RTN_LOGIC', type: 'ground', direction: 'return' },
          { id: '5', name: 'ANA_CMD_POS', type: 'analog', direction: 'input', signal: '±10V' },
          { id: '6', name: 'ANA_FB_POS', type: 'analog', direction: 'output', signal: '0-5V' }
        ]
      }
    ]
  },

  // SYS-005 雷达导引头
  'SYS-005': {
    type: 'SYS-005',
    name: '雷达导引头',
    description: '目标探测与跟踪，射频+数据接口',
    icon: RadioOutline,
    color: '#6f42c1',
    subsystem: '末制导',
    defaultData: {
      label: '雷达导引头',
      type: 'SYS-005',
      specifications: {
        function: '发射/接收雷达波，锁定目标',
        interfaces: '射频+数据接口'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/23-26-40',
        pinCount: 40,
        pins: [
          { id: 'A1', name: 'PWR_28V', type: 'power', direction: 'input', signal: '28V DC, 10A' },
          { id: 'A2', name: 'PWR_RTN', type: 'ground', direction: 'return' },
          { id: 'B1', name: 'FIBER_TX', type: 'fiber', direction: 'output', signal: '1000BASE-SX' },
          { id: 'B2', name: 'FIBER_RX', type: 'fiber', direction: 'input', signal: '1000BASE-SX' },
          { id: 'C1', name: 'DIS_TGT_LOCK', type: 'discrete', direction: 'output', signal: '5V TTL' },
          { id: 'C2', name: 'ANA_AGC_VOLT', type: 'analog', direction: 'output', signal: '0-5V' }
        ]
      }
    ]
  },

  // SYS-006 战斗部安全与解保装置
  'SYS-006': {
    type: 'SYS-006',
    name: '战斗部安全装置',
    description: '控制战斗部起爆，安全性关键设备',
    icon: ShieldCheckmarkOutline,
    color: '#c41d7f',
    subsystem: '战斗部',
    defaultData: {
      label: '战斗部安全装置',
      type: 'SYS-006',
      specifications: {
        function: '接收解保和起爆指令',
        criticality: '安全性关键设备'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/16-26-20',
        pinCount: 20,
        pins: [
          { id: '10', name: 'IGNITION_CMD', type: 'discrete', direction: 'input', signal: '28V, 500mA' },
          { id: '11', name: 'SAFE_ARM_STATUS', type: 'discrete', direction: 'output', signal: '5V TTL' },
          { id: '12', name: 'PWR_28V', type: 'power', direction: 'input', signal: '28V DC, 0.1A' },
          { id: '13', name: 'GND', type: 'ground', direction: 'return' }
        ]
      }
    ]
  },

  // SYS-007 数据链终端
  'SYS-007': {
    type: 'SYS-007',
    name: '数据链终端',
    description: '与发射平台通信，天线+数据接口',
    icon: WifiOutline,
    color: '#009999',
    subsystem: '通信',
    defaultData: {
      label: '数据链终端',
      type: 'SYS-007',
      specifications: {
        function: '接收目标更新、传输状态',
        interfaces: '天线+数据接口'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/23-26-40',
        pinCount: 40,
        pins: [
          { id: 'A1', name: 'PWR_28V', type: 'power', direction: 'input', signal: '28V DC, 2A' },
          { id: 'A2', name: 'GND', type: 'ground', direction: 'return' },
          { id: 'B1', name: 'ETH_TX_P', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'B2', name: 'ETH_TX_N', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'B3', name: 'ETH_RX_P', type: 'ethernet', direction: 'input', signal: '1000BASE-T' },
          { id: 'B4', name: 'ETH_RX_N', type: 'ethernet', direction: 'input', signal: '1000BASE-T' }
        ]
      }
    ]
  },

  // SYS-008 主电源分配单元
  'SYS-008': {
    type: 'SYS-008',
    name: '主电源分配单元',
    description: '电力分配与管理',
    icon: ServerOutline,
    color: '#876e27',
    subsystem: '电源',
    defaultData: {
      label: '主电源分配单元',
      type: 'SYS-008',
      specifications: {
        function: '从电池取电，分配至全弹'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/26-26-100',
        pinCount: 100,
        pins: [
          { id: 'MAIN_IN', name: 'PWR_IN_MAIN', type: 'power', direction: 'input', signal: '28V DC, 50A' },
          { id: 'MAIN_RTN', name: 'PWR_RTN_MAIN', type: 'ground', direction: 'return' },
          { id: 'P1', name: 'PWR_OUT_01', type: 'power', direction: 'output', signal: '28V DC, 5A' },
          { id: 'P2', name: 'RTN_01', type: 'ground', direction: 'return' },
          { id: 'P3', name: 'PWR_OUT_02', type: 'power', direction: 'output', signal: '28V DC, 1A' },
          { id: 'P4', name: 'RTN_02', type: 'ground', direction: 'return' },
          { id: 'P5', name: 'PWR_OUT_03', type: 'power', direction: 'output', signal: '28V DC, 10A' },
          { id: 'P6', name: 'RTN_03', type: 'ground', direction: 'return' },
          { id: 'P7', name: 'PWR_OUT_04', type: 'power', direction: 'output', signal: '28V DC, 2A' },
          { id: 'P8', name: 'RTN_04', type: 'ground', direction: 'return' },
          { id: 'P9', name: 'PWR_OUT_05', type: 'power', direction: 'output', signal: '28V DC, 3A' },
          { id: 'P10', name: 'RTN_05', type: 'ground', direction: 'return' },
          { id: 'P11', name: 'PWR_OUT_06_MOTOR', type: 'power', direction: 'output', signal: '28V DC, 15A' },
          { id: 'P12', name: 'RTN_06_MOTOR', type: 'ground', direction: 'return' },
          { id: 'P13', name: 'PWR_OUT_07_LOGIC', type: 'power', direction: 'output', signal: '28V DC, 0.5A' },
          { id: 'P14', name: 'RTN_07_LOGIC', type: 'ground', direction: 'return' },
          { id: 'P15', name: 'PWR_OUT_08', type: 'power', direction: 'output', signal: '28V DC, 1.5A' },
          { id: 'P16', name: 'RTN_08', type: 'ground', direction: 'return' },
          { id: 'P17', name: 'PWR_OUT_09', type: 'power', direction: 'output', signal: '28V DC, 0.1A' },
          { id: 'P18', name: 'RTN_09', type: 'ground', direction: 'return' }
        ]
      }
    ]
  },

  // SYS-009 热电池
  'SYS-009': {
    type: 'SYS-009',
    name: '热电池',
    description: '一次电源，导弹发射后激活',
    icon: FlashOutline,
    color: '#d46b08',
    subsystem: '电源',
    defaultData: {
      label: '热电池',
      type: 'SYS-009',
      specifications: {
        function: '提供全弹电力',
        type: '一次电源'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/26-26-10',
        pinCount: 10,
        pins: [
          { id: '1', name: 'PWR_OUT_28V', type: 'power', direction: 'output', signal: '28V DC, 50A' },
          { id: '2', name: 'PWR_RTN', type: 'ground', direction: 'return' },
          { id: '3', name: 'DIS_ACTIVATE', type: 'discrete', direction: 'input', signal: '5-28V, 1A' }
        ]
      }
    ]
  },

  // SYS-010 网络交换机
  'SYS-010': {
    type: 'SYS-010',
    name: '网络交换机',
    description: '高速数据交换',
    icon: GitBranchOutline,
    color: '#389e0d',
    subsystem: '数据通信',
    defaultData: {
      label: '网络交换机',
      type: 'SYS-010',
      specifications: {
        function: '为高速设备提供以太网交换'
      }
    },
    connectors: [
      {
        id: 'J1',
        type: 'J599/26-26-60',
        pinCount: 60,
        pins: [
          { id: 'A1', name: 'PWR_28V', type: 'power', direction: 'input', signal: '28V DC, 3A' },
          { id: 'A2', name: 'GND', type: 'ground', direction: 'return' },
          { id: 'PORT1_TX_P', name: 'ETH1_TX_P', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'PORT1_TX_N', name: 'ETH1_TX_N', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'PORT1_RX_P', name: 'ETH1_RX_P', type: 'ethernet', direction: 'input', signal: '1000BASE-T' },
          { id: 'PORT1_RX_N', name: 'ETH1_RX_N', type: 'ethernet', direction: 'input', signal: '1000BASE-T' },
          { id: 'PORT2_FIBER', name: 'FIBER_PORT2', type: 'fiber', direction: 'bidirectional', signal: '1000BASE-SX' },
          { id: 'PORT3_TX_P', name: 'ETH3_TX_P', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'PORT3_TX_N', name: 'ETH3_TX_N', type: 'ethernet', direction: 'output', signal: '1000BASE-T' },
          { id: 'PORT3_RX_P', name: 'ETH3_RX_P', type: 'ethernet', direction: 'input', signal: '1000BASE-T' },
          { id: 'PORT3_RX_N', name: 'ETH3_RX_N', type: 'ethernet', direction: 'input', signal: '1000BASE-T' }
        ]
      }
    ]
  }
}